/*
 * System:  <???>
 * File:    iic.h
 *          Global header for i2c software implementation
 *
 * (C) Copyright PinGrid Oy (mi) 1994 - All rights reserved
 *
 *$Id: iic.h 1.1 95/03/03 13:53:11 mi Exp $
 *
 *$Log: iic.h $
 * Revision 1.1  95/03/03  13:53:11  mi
 * Initial revision
 * 
 */

#ifndef _IIC_H
#define _IIC_H
 

/*
 * Compiler/machine dependencies
 */

#ifndef __TYPES_DEFINED
#define __TYPES_DEFINED
typedef unsigned char bit;
typedef unsigned char byte;
typedef unsigned int word;
#endif


/*
 * Prototypes for functions in iic.c (and iic51.s03)
 */

bit i2c_reset(void);
bit i2c_start(void);
bit i2c_stop(void);
bit i2c_send_ex(byte addr, byte count, bit send_stop);
bit i2c_recv(byte addr, byte count);
bit i2c_send_recv(byte addr, byte tx_count, byte rx_count);
bit i2c_byte_out(byte);

bit i2c_recv_one(byte addr, byte reg, byte * pdat);
bit i2c_send_one(byte addr, byte reg, byte dat);

bit i2c_send_nfc(byte * pdat,byte size);
bit i2c_recv_nfc(byte * pdat,byte size);
unsigned char GetIrqOutPin(void);

/*
 * Macro for normal send transfer ending with a stop condition
 */

//#define i2c_send(addr, count)   i2c_send_ex(addr, count, 1)

/*
 * Global variables in iic.c
 */

extern byte i2c_error;          /* Set to last error value, see below */
 
/*
 * I2C error values
 */

#define I2CERR_OK       0       /* No error */
#define I2CERR_NAK      1       /* No ACK from slave */
#define I2CERR_LOST     2       /* Arbitration lost */
#define I2CERR_BUS      3       /* Bus is stuck (not used yet) */
#define I2CERR_TIMEOUT  4       /* Timeout on bus */

#endif
